
const shareLocationKey = "share_location"

const defaultAvatarUrl = '/resources/outline_article_black_24dp.png'
Page({
    data: {
        avatarUrl: '',
        res:defaultAvatarUrl,
         shareLocation: false,

    },
    onLoad: function (options) {
    },

    onShareLocation(e: any) {
        this.data.shareLocation = e.detail.value
        wx.setStorageSync(shareLocationKey, this.data.shareLocation)
    },

    onChooseAvatar(e:any){
        console.log(e.detail)
        console.log("你好")
        this.setData({
            avatarUrl: e.detail.avatarUrl,
            shareLocation: true,
        })
        wx.setStorageSync(shareLocationKey, true)
        console.log(this.data.shareLocation)
    },

    onUnlockTap(){

        wx.getLocation({
            type: 'gcj02', // 返回坐标类型：GCJ02
            success: res => {
                // 使用经纬度打开微信地图
                return
            },
            fail: err => {
                wx.showToast({
                    icon: 'none',
                    title: "请前往设计页进行设置允许"
                })
                console.error('获取地理位置失败', err);
            }
        })


         wx.showLoading({
             title:'开锁中',
             mask: true,
         })
        setTimeout(()=>{
            wx.redirectTo({
                url: '/pages/driving/driving',
                complete :()=>{
                    wx.hideLoading()
                }
            })
        },2000)
    },
});